package main

import "fmt"

type S struct {
	data string
}

func (s S) Read() string {
	return s.data
}

func (s *S) Write(str string) {
	s.data = str
}

type F interface {
	f() string
}

type S1 struct {
}

func (s S1) f() string { return "8888" }

type S2 struct {
}

func (s *S2) f() string { return "9999" }

func main() {

	sVals := map[int]*S{1: {"A"}}
	sVals[1].Write("test")
	fmt.Println(sVals[1].Read())

	println("---------------")
	s1Val := S1{}
	s1Ptr := &S1{}
	s2Val := S2{}
	s2Ptr := &S2{}

	var i F
	i = s1Val
	i = s1Ptr
	i = s2Ptr
	// 下面代码编译不通过， S2的 f() 没有使用 值接收器
	//i = s2Val
	fmt.Println(s2Val)
	fmt.Println(i.f())

}
